package com.augurit.gzcgwsp.zzgqba.convert;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.augurit.common.util.lang.DateUtils;
import com.augurit.gzcgwsp.zzgqba.entity.YwRqZzgqba;
import com.augurit.gzcgwsp.zzgqba.web.form.YwRqZzgqbaForm;


public class YwRqZzgqbaConvertor {
	public static YwRqZzgqbaForm convertVoToForm(YwRqZzgqba entity) {
		if(entity != null) {
			YwRqZzgqbaForm form = new YwRqZzgqbaForm();
			form.setId(entity.getId());
			form.setAcceptNo(entity.getAcceptNo());
			form.setSqdw(entity.getSqdw());
			form.setZzgqyhqk(entity.getZzgqyhqk());
			form.setSmsq(entity.getSmsq());
			form.setGyqht(entity.getGyqht());
			form.setYhwzfxgzj(entity.getYhwzfxgzj());
			form.setCjtz(entity.getCjtz());
			form.setCjxgzj(entity.getCjxgzj());
			form.setTqjhap(entity.getTqjhap());
			form.setSfsmcj(entity.getSfsmcj());
			form.setCjbzf(entity.getCjbzf());
			form.setTqba(entity.getTqba());
			form.setQtqk(entity.getQtqk());
			form.setZhpj(entity.getZhpj());
			form.setSjr(entity.getSjr());
			form.setSjsj(entity.getSjsj());
			form.setCbyw(entity.getCbyw());
			form.setLxr(entity.getLxr());
			form.setLxdh(entity.getLxdh());
			form.setCbbm(entity.getCbbm());
			form.setCpsj(entity.getCpsj());
			form.setDfsj(entity.getDfsj());
			form.setSendNotice(entity.getSendNotice());
			form.setIsycbl(entity.getIsycbl());
			form.setYslNo(entity.getYslNo());
			form.setBusinessCode(entity.getBusinessCode());
			form.setApprovalNo(entity.getApprovalNo());
			form.setYsl(entity.getYsl());
			form.setJar(entity.getJar());
			form.setJbrxm(entity.getJbrxm());
			form.setJarq(entity.getJarq());
			form.setLarq(entity.getLarq());
			form.setSqrq(entity.getSqrq());
			form.setSarq(entity.getSarq());
			return form;
		}else
			return null;
	}
	
	public static void convertFormToVo(YwRqZzgqbaForm form, YwRqZzgqba entity) {
		if(entity != null && form != null) {
			entity.setId(form.getId());
			if(form.getAcceptNo() != null && form.getAcceptNo().trim().length() > 0)
				entity.setAcceptNo(form.getAcceptNo().trim());
			if(form.getSqdw() != null && form.getSqdw().trim().length() > 0)
				entity.setSqdw(form.getSqdw().trim());
			if(form.getZzgqyhqk() != null && form.getZzgqyhqk().trim().length() > 0)
				entity.setZzgqyhqk(form.getZzgqyhqk().trim());
			if(form.getSmsq() != null && form.getSmsq().trim().length() > 0)
				entity.setSmsq(form.getSmsq().trim());
			if(form.getGyqht() != null && form.getGyqht().trim().length() > 0)
				entity.setGyqht(form.getGyqht().trim());
			if(form.getYhwzfxgzj() != null && form.getYhwzfxgzj().trim().length() > 0)
				entity.setYhwzfxgzj(form.getYhwzfxgzj().trim());
			if(form.getCjtz() != null && form.getCjtz().trim().length() > 0)
				entity.setCjtz(form.getCjtz().trim());
			if(form.getCjxgzj() != null && form.getCjxgzj().trim().length() > 0)
				entity.setCjxgzj(form.getCjxgzj().trim());
			if(form.getTqjhap() != null && form.getTqjhap().trim().length() > 0)
				entity.setTqjhap(form.getTqjhap().trim());
			if(form.getSfsmcj() != null && form.getSfsmcj().trim().length() > 0)
				entity.setSfsmcj(form.getSfsmcj().trim());
			if(form.getCjbzf() != null && form.getCjbzf().trim().length() > 0)
				entity.setCjbzf(form.getCjbzf().trim());
			if(form.getTqba() != null && form.getTqba().trim().length() > 0)
				entity.setTqba(form.getTqba().trim());
			if(form.getQtqk() != null && form.getQtqk().trim().length() > 0)
				entity.setQtqk(form.getQtqk().trim());
			if(form.getZhpj() != null && form.getZhpj().trim().length() > 0)
				entity.setZhpj(form.getZhpj().trim());
			if(form.getSjr() != null && form.getSjr().trim().length() > 0)
				entity.setSjr(form.getSjr().trim());
			entity.setSjsj(form.getSjsj());
			if(form.getCbyw() != null && form.getCbyw().trim().length() > 0)
				entity.setCbyw(form.getCbyw().trim());
			if(form.getLxr() != null && form.getLxr().trim().length() > 0)
				entity.setLxr(form.getLxr().trim());
			if(form.getLxdh() != null && form.getLxdh().trim().length() > 0)
				entity.setLxdh(form.getLxdh().trim());
			if(form.getCbbm() != null && form.getCbbm().trim().length() > 0)
				entity.setCbbm(form.getCbbm().trim());
			entity.setCpsj(form.getCpsj());
			entity.setDfsj(form.getDfsj());
			if(form.getJar() != null && form.getJar().trim().length() > 0)
				entity.setJar(form.getJar().trim());
			if(form.getSendNotice() != null && form.getSendNotice().trim().length() > 0)
				entity.setSendNotice(form.getSendNotice().trim());
			if(form.getJbrxm() != null && form.getJbrxm().trim().length() > 0)
				entity.setJbrxm(form.getJbrxm().trim());
			entity.setJarq(form.getJarq());
			entity.setLarq(form.getLarq());
			if(form.getIsycbl() != null && form.getIsycbl().trim().length() > 0)
				entity.setIsycbl(form.getIsycbl().trim());
			if(form.getYslNo() != null && form.getYslNo().trim().length() > 0)
				entity.setYslNo(form.getYslNo().trim());
			if(form.getBusinessCode() != null && form.getBusinessCode().trim().length() > 0)
				entity.setBusinessCode(form.getBusinessCode().trim());
			if(form.getApprovalNo() != null && form.getApprovalNo().trim().length() > 0)
				entity.setApprovalNo(form.getApprovalNo().trim());
			entity.setSqrq(form.getSqrq());
			entity.setYsl(form.getYsl());
			entity.setSarq(form.getSarq());
		}
	}
	
	public static List<YwRqZzgqbaForm> convertVoListToFormList(List<YwRqZzgqba> ywRqZzgqbaList) {
		if(ywRqZzgqbaList != null && ywRqZzgqbaList.size() > 0) {
			List<YwRqZzgqbaForm> ywRqZzgqbaFormList = new ArrayList();
			for(int i=0; i<ywRqZzgqbaList.size(); i++) {
				ywRqZzgqbaFormList.add(convertVoToForm(ywRqZzgqbaList.get(i)));
			}
			return ywRqZzgqbaFormList;
		}
		return null;
	}
	
	public static List<Map> convertVoListToMapList(List<YwRqZzgqba> ywRqZzgqbaList) {
		if(ywRqZzgqbaList != null && ywRqZzgqbaList.size() > 0) {
			List<Map> mapList = new ArrayList();
			for(int i=0; i<ywRqZzgqbaList.size(); i++) {
				YwRqZzgqba entity = ywRqZzgqbaList.get(i);
				Map<String, String> map = new HashMap();

				map.put("id", entity.getId() == null ? "" : entity.getId().toString());
				map.put("acceptNo", entity.getAcceptNo());
				map.put("sqdw", entity.getSqdw());
				map.put("zzgqyhqk", entity.getZzgqyhqk());
				map.put("smsq", entity.getSmsq());
				map.put("gyqht", entity.getGyqht());
				map.put("yhwzfxgzj", entity.getYhwzfxgzj());
				map.put("cjtz", entity.getCjtz());
				map.put("cjxgzj", entity.getCjxgzj());
				map.put("tqjhap", entity.getTqjhap());
				map.put("sfsmcj", entity.getSfsmcj());
				map.put("cjbzf", entity.getCjbzf());
				map.put("tqba", entity.getTqba());
				map.put("qtqk", entity.getQtqk());
				map.put("zhpj", entity.getZhpj());
				map.put("sjr", entity.getSjr());
				map.put("sjsj", DateUtils.dateTimeToString(entity.getSjsj(), "yyyy-MM-dd"));
				map.put("lxr", entity.getLxr());
				map.put("lxdh", entity.getLxdh());
				map.put("cbbm", entity.getCbbm());
				map.put("cpsj", DateUtils.dateTimeToString(entity.getCpsj(), "yyyy-MM-dd"));
				map.put("dfsj", DateUtils.dateTimeToString(entity.getDfsj(), "yyyy-MM-dd"));
				map.put("sendNotice", entity.getSendNotice());
				map.put("isycbl", entity.getIsycbl());
				map.put("yslNo", entity.getYslNo());
				map.put("businessCode", entity.getBusinessCode());
				map.put("approvalNo", entity.getApprovalNo());
				map.put("ysl", entity.getYsl() == null ? "" : entity.getYsl().toString());
				map.put("slsj", DateUtils.dateTimeToString(entity.getSlsj(), "yyyy-MM-dd"));
				map.put("cbyw", entity.getCbyw());
				map.put("jar", entity.getJar());
				map.put("sqrq", DateUtils.dateTimeToString(entity.getSqrq(), "yyyy-MM-dd"));
				map.put("sarq", DateUtils.dateTimeToString(entity.getSarq(), "yyyy-MM-dd"));
				map.put("jbrxm", entity.getJbrxm());
				map.put("jarq", DateUtils.dateTimeToString(entity.getJarq(), "yyyy-MM-dd"));
				map.put("larq", DateUtils.dateTimeToString(entity.getLarq(), "yyyy-MM-dd"));
				
				mapList.add(map);
			}
			return mapList;
		}
		return null;
	}
	
	public static List<YwRqZzgqba> convertFormListToVoList(List<YwRqZzgqbaForm> ywRqZzgqbaFormList) {
		if(ywRqZzgqbaFormList != null && ywRqZzgqbaFormList.size() > 0) {
			List<YwRqZzgqba> ywRqZzgqbaList = new ArrayList();
			for(int i=0; i<ywRqZzgqbaFormList.size(); i++) {
				YwRqZzgqba ywRqZzgqba = new YwRqZzgqba();
				convertFormToVo(ywRqZzgqbaFormList.get(i), ywRqZzgqba);
				ywRqZzgqbaList.add(ywRqZzgqba);
			}
			return ywRqZzgqbaList;
		}
		return null;
	}
}